package com.c5c7.Servlet;

import com.c5c7.bean.NewsBean;
import com.c5c7.dao.NewsDao;
import jakarta.servlet.ServletException;
import jakarta.servlet.annotation.WebServlet;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;

import java.io.IOException;
import java.util.List;


@WebServlet("/news.jsp")
public class NewsServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        NewsDao newsDao = new NewsDao();
        List<NewsBean> news = newsDao.getList();
        req.setAttribute("news", news);
        req.getRequestDispatcher("newstemp.jsp").forward(req, resp);
    }
}
